package com.zhao.dota.security;

import com.zhao.dota.bo.AuthenticateUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtil {

    public static AuthenticateUser getAuthenticateUser() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication != null) {
            Object principal = authentication.getPrincipal();
            if (principal instanceof AuthenticateUser) {
                return (AuthenticateUser) principal;
            }
        }
        return null;
    }

}
